<?php
/**
 * Created by PhpStorm.
 * User: 84071
 * Date: 2018-03-23
 * Time: 16:21
 */
namespace app\common\model;
use think\Model;

class Advertising extends Model{
    // 开启自动写入时间戳
    protected $autoWriteTimestamp = true;
    protected $insert = ['addtime'];
    protected $update = ['uptime'];
    protected $type = [
        'addtime'    => 'timestamp',
        'uptime'    => 'timestamp',
    ];
    protected $createTime = 'addtime';
    protected $updateTime = 'uptime';
    // 启用状态
    protected function getStatuszhAttr($value,$data){
        $status = [ 0 => '<a data-id="'.$data['id'].'" data-href="'.url('Advertising/see').'" class="cx-click" data-type="sestatus">隐藏</a>',1 => '<a data-id="'.$data['id'].'" data-href="'.url('Advertising/see').'" class="cx-click" data-type="sestatus">显示</a>'];
        return $status[$data['status']];
    }
    protected function getSeetypezhAttr($value,$data){
        $status = [ 1 => '图片广告', 2 => '幻灯片广告', 3 => '图文广告', 4 => '文字广告'];
        return $status[$data['seetype']];
    }
    public function get_one($id){
        $arr = $this->where('id',$id)->find();
        if(empty($arr) || $arr['status'] != '1'){
            return false;
        }
        $getone = $arr->toArray();
        $getone['cont'] = unserialize($getone['cont']);
        return $getone;
    }

}